package modular.mapreduce;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.log4j.BasicConfigurator;

public class JobSubmitter2 {

    public static void main(String[] args) throws Exception {
        BasicConfigurator.configure();


        Configuration conf = new Configuration();

        Job job = Job.getInstance(conf);
        job.setJarByClass(JobSubmitter2.class);

        job.setMapperClass(WordCountMapper.class);
        job.setReducerClass(WordCountReduce.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputKeyClass(IntWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        FileInputFormat.setInputPaths(job,new Path("/yue/"));
        FileOutputFormat.setOutputPath(job,new Path("/yue/output"));

        job.setNumReduceTasks(3);
        boolean b = job.waitForCompletion(true);
        System.exit(b?0:1);

    }
}
